package ui.faces.management
{
	import global.Managers;
	
	import ui.components.renderlist.RenderList;
	import ui.faces.AbstractFace;
	import ui.faces.management.vo.ApplyPayRendererVO;
	
	/**
	 * 该界面为总台客户端专用
	 * @author Raykid
	 */	
	public class ManagementFace extends AbstractFace
	{
		private var _applyPayList				: RenderList;
		
		public function ManagementFace()
		{
			super();
		}
		override protected function createBG():void {
			super.createBG();
			_bg.addChild(Managers.resourceManager.getBitmap("faces/managementBG.jpg"));
		}
		override protected function createView():void {
			super.createView();
			
			_applyPayList = new RenderList();
			_applyPayList.itemNumHorizon = 1;
			_applyPayList.itemNumVerticle = 10;
			_applyPayList.x = 10;
			_applyPayList.y = 10;
			addChild(_applyPayList);
		}
		override protected function initListener():void {
			super.initListener();
			
			Managers.serverManager.subscribe("PayBill", payBillHandler);
			Managers.serverManager.subscribe("UpdateApplyPay", applyPayHandler);
		}
		private function payBillHandler(data:Object):void {
			getApplyPayList();
		}
		private function applyPayHandler(data:Object):void {
			var applys:Array = data as Array;
			var applyArr:Array = [];
			for(var i:int = 0; i < applys.length; i++) {
				var apply:Object = applys[i];
				var value:ApplyPayRendererVO = new ApplyPayRendererVO();
				value.tableID = apply.id;
				value.disheIDs = apply.dishes;
				applyArr.push(value);
			}
			_applyPayList.setDataProvider(applyArr);
		}
		
		public function getApplyPayList():void {
			Managers.serverManager.send("UpdateApplyPay");
		}
		/**
		 *
		 * 切换语言 
		 * @param toLanguage 切换到的语言
		 * 
		 */
		override public function switchLanguage(toLanguage:int):void
		{
			super.switchLanguage(toLanguage);
			
			if(toLanguage == _currentLanguage) return;
			_currentLanguage = toLanguage;
		}
	}
}